package com.huahua.api.entity.base;

import lombok.Data;

/**
 * @author LoveHuahua
 * @date 2021年09月07日 14:39
 * @description believe in yourself
 */
@Data
public class R<T> {

    private int code;

    private String message;

    private T data;

    public static <T> R<T> success(T t) {
        R<T> objectR = new R<>();
        objectR.setMessage("操作成功");
        objectR.setCode(200);
        objectR.setData(t);
        return objectR;
    }

    public static <T> R<T> error(String message) {
        return error(-1,message);
    }


    public static <T> R<T> error(int code, String message) {
        R<T> objectR = new R<>();
        objectR.setMessage(message);
        objectR.setCode(code);
        objectR.setData(null);
        return objectR;
    }


}
